package svc

import (
	"go-zero/common/init_db"
	"go-zero/user-jwt/internal/config"
	"gorm.io/gorm"
)

type ServiceContext struct {
	Config config.Config
	DB     *gorm.DB
}

func NewServiceContext(c config.Config) *ServiceContext {
	Db := init_db.InitGorm(
		c.MySql.User,
		c.MySql.Password,
		c.MySql.Host,
		c.MySql.Db,
		c.MySql.Port,
		c.MySql.MaxIdle,
		c.MySql.MaxOpen,
	)
	return &ServiceContext{
		Config: c,
		DB:     Db,
	}
}
